import { message } from "antd";
import axios from "axios";

const request = axios.create({
    baseURL: process.env.REACT_APP_TRADEMARK_API,
    timeout: 10000,
});

request.interceptors.request.use((config) => {
    return config;
});

request.interceptors.response.use((response) => {
    if (response.data.code === 200) {
        return response.data.data;
    }
    else {
        const errorMsg = response.data.data || response.data.message
        message.info(errorMsg);
        return Promise.reject(errorMsg);
    }
}, (error) => {
    message.info(error.message);
    return Promise.reject(error);
})

export default request;